Optimize column_encryption_policy checks in recv_results_rows#630
Optimize column_encryption_policy checks in recv_results_rows#630mykaul wants to merge 6 commits intoscylladb:masterfrom
Conversation
|
CI failure is unrelated, and I've seen it happening on too many PRs already :-/ |
| from cassandra.protocol import ResultMessage, RESULT_KIND_ROWS | ||
|
|
||
|
|
||
| class DecodeOptimizationTest(unittest.TestCase): |
There was a problem hiding this comment.
Could you please move this class to tests/unit/test_protocol.py and rename it to ResultTest
| if __name__ == '__main__': | ||
| unittest.main() |
3a9031e to
ad8b6f9
Compare
dkropachev
left a comment
There was a problem hiding this comment.
numpy_parser.pyx, parsing.pyx also needs to be fixed
76c09ae to
f44a9ba
Compare
It wasn't clear to me what needs to fixing there: |
Instead of changing only While Abstract classes: |
Let me see if I understand this:
Is that an accurate representation?
I'm not sure I understand the interaction between Python and Cython - I was not going to change the interfaces whatsoever.
You raise a good point about the names of the functions - that can clearly be more clear with 'plain' and 'encrypted' in them! I'll fix that. |
f44a9ba to
132859f
Compare
There's no point in checking a global policy for every single value decoding, not for every row decoded. Adjusted the code to only check it once per recv_results_rows() call - decode_row() should be defined either as is today with column_encryption_policy enabled, or much simpler without all those extra checks. Added a unit test from CoPilot. Fixes: scylladb#582 Signed-off-by: Yaniv Kaul <yaniv.kaul@scylladb.com>
…ack_row() function Very similar to the native Python code, separate the two cases, if column encryption (CE) policy is not enabled, the code is substantially simplified. If it is, it's slightly more elaborate. Decided to have two loops in two functions, one for each case, for performance reasons, even if readability-wise it's not as great. AI agreed with me: Recommendation: Keep it as is. In high-performance Cython code like this, duplicating a small block of code Fixes: scylladb#639 Signed-off-by: Yaniv Kaul <yaniv.kaul@scylladb.com>
Add tests, respond to review feedback on added tests. Signed-off-by: Yaniv Kaul <yaniv.kaul@scylladb.com>
Split BoundStatement.bind() into CE and non-CE loops to avoid per-value CE checks when no policy is configured. In the CE loop, use a single uses_ce branch to select type serialization and optional encryption for each column. Signed-off-by: Yaniv Kaul <yaniv.kaul@scylladb.com>
…_col_encrypted_row() Per review comments. Signed-off-by: Yaniv Kaul <yaniv.kaul@scylladb.com>
132859f to
d87f917
Compare
Done in latest commit. I think it's ready for re-review. |
|
CI failure seems like known issue #446 |
Instead, do it outside the loop. Signed-off-by: Yaniv Kaul <yaniv.kaul@scylladb.com>
There's no point in checking a global policy for every single value decoding, not for every row decoded.
Adjusted the code to only check it once per recv_results_rows() call - decode_row() should be defined either as is today with column_encryption_policy enabled,
or much simpler without all those extra checks.
Added a unit test from CoPilot.
Fixes: #582
Pre-review checklist
./docs/source/.Fixes:annotations to PR description.